package com.thesis.teacher.feign.fallback;

import com.thesis.manage.common.exception.CommonException;
import com.thesis.manage.common.utils.Result;
import com.thesis.manage.service.constant.ErrorMessage;
import com.thesis.manage.service.model.StateCodeEnum;
import com.thesis.teacher.feign.UserService;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author php
 * @date 2018/1/24
 */
@Component
public class UserServiceFallback implements UserService {
    @Override
    public Result register(@RequestParam("account") String account, @RequestParam("password") String password, @RequestParam("type") Integer type) {
        return Result.build(StateCodeEnum.NETWORKERROR.getValue(), ErrorMessage.NETWORK_ERROR);
    }

    @Override
    public Result login(@RequestParam("account") String account, @RequestParam("password") String password, @RequestParam("type") Integer type) {
        return Result.build(StateCodeEnum.NETWORKERROR.getValue(), ErrorMessage.NETWORK_ERROR);
    }

    @Override
    public Result findUserByToken(@RequestParam("token") String token) {
        return Result.build(StateCodeEnum.NETWORKERROR.getValue(), ErrorMessage.NETWORK_ERROR);
    }

    @Override
    public Result checkToken(@RequestParam("token") String token) {
        return Result.build(StateCodeEnum.NETWORKERROR.getValue(), ErrorMessage.NETWORK_ERROR);
    }

    @Override
    public void expire(@RequestParam("token") String token, @RequestParam("type") Integer type) {
        throw new CommonException("Internal error of the system", ErrorMessage.NETWORK_ERROR);
    }

    @Override
    public Result logout(@RequestParam("token") String token) {
        return Result.build(StateCodeEnum.NETWORKERROR.getValue(), ErrorMessage.NETWORK_ERROR);
    }
}
